
*********************************************
*** Program to Produce Figure 1 of Appendix *
*********************************************

clear
drop _all
set more off

cd "$US_Ineq_Repl"
local Processed = "$US_Ineq_Repl/Processed"
local FFL = "$US_Ineq_Repl/Scripts/FFL"

// customize your file path
cd "`FFL'"
global data "`c(pwd)'\Data"
global figure "`c(pwd)'\Figures"


*** find minimum wages ***

local year_b=2020
local year86=1986
local year15=2015

use "$US_Ineq_Repl/Processed/CPI_mwage.dta", replace

local row=`year86'-1977
local cpi86=cpi in `row'
local mwage86=minwage in `row'
di `mwage86'

local row=`year15'-1977
local cpi15=cpi in `row'
local mwage15=minwage in `row'
di `mwage15'

local row=`year_b'-1977
local cpi_b=cpi in `row'

local mwage86=`mwage86'*(`cpi_b'/`cpi86')
local mwage15=`mwage15'*(`cpi_b'/`cpi15')

local lmw86=log(`mwage86')
local lmw15=log(`mwage15')

di `lmw86'
di `lmw15'

*** import data and append***
use $data\us86.dta
append using $data\us15.dta
append using $data\us86rw15.dta

tab time

// highest state min wage
local mxmw=9
local mxmw=log(`mxmw')+log(`cpi_b'/`cpi15')

*replace mxmw=10 if year >=114 & year<=116


*** generate quantile data ***

global option at(eval) gauss nograph
pctile eval=lrwage3  if time==0 | time==1 [aweight=orgwgt], nq(1500)
kdensity lrwage3 if time==0 [aweight=orgwgt], gen(eval0 dens0) width(0.06) $option
kdensity lrwage3 if time==1 [aweight=orgwgt], gen(eval1 dens1) width(0.08) $option
kdensity lrwage3 if time==2 [aweight=orgwgt], gen(eval2 dens2) width(0.06) $option

keep dens* eval*
duplicates drop
sort eval
*drop if eval>5.26

*** plot ***

set scheme s1color
graph twoway (connected dens0 eval0 if eval0>=1.5 & eval0<=4.7, m(i) clw(medium) lp(longdash) mc(blue) lc(blue)) ///
	(connected dens1 eval1 if eval1>=1.5 & eval1<=4.7, m(i) clw(medium) lp(solid) mc(red) lc(red)) ///
	(connected dens2 eval2 if eval2>=1.5 & eval2<=4.7, m(i) clw(medium) lp(dash) mc(green) lc(green)) , /// 
	yti("Density", marg(0 2 0 0)) ylabel(0(.1).7) xti("Log Wages", marg(0 0 0 2)) ///
	xlabel(1.6 "ln(5)" 2.3 "ln(10)" 3.0 "ln(20)" 3.7 "ln(40)" 4.4 "ln(80)") ///
	xscale(r(1.5 5)) text(0.7 1.9 "Minimum Wages") ///
	xline(`lmw86', lw(thin) lc(eltblue) lp(solid)) ///
	xline(`mxmw', lw(thin) lc(erose) lp(solid)) ///
	legend( lab(1 "1986") lab(2 "2015") lab(3 "1986 rwgt 2015")  ///
	order(1 3 2) pos(6) col(2) region(lstyle(none)) symxsize(8) keygap(1) ///
	textwidth(32)) saving($figure\fig1.gph , replace)
graph export $figure\fig1.pdf , replace
graph export $US_Ineq_Repl\Results\Figures\FigF1.png , replace


